<%--
  Created by IntelliJ IDEA.
  User: root
  Date: 2021/3/21
  Time: 9:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    pageContext.setAttribute("basePath",basePath);
%>
<%@taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>

<html>
<head>
    <title>员工列表</title>
    <%--
        Bootstrap搭建页面
    --%>
    <%--
    Web路径不以开始的相对路径，找资源，以当前资源的路径为基准，经常容易出问题
    --%>
</head>

<link rel="stylesheet" href="${basePath}static/css/bootstrap.min.css"/>
<link rel="stylesheet" href="${basePath}static/img/bootstrap-icons-1.4.0/fonts/bootstrap-icons.css">
<body>
<div class="container">
    <!--标题-->
    <div class="row">
        <div class="col-md-12">
            <h1>SSM-CRUD</h1>
        </div>
    </div>
    <!--按钮-->
    <div class="row">
        <div class="col-md-4 offset-md-8">
            <button class="btn-success">
                <svg class="bi" fill="currentColor" width="16" height="16">
                    <use xlink:href="${basePath}static/img/bootstrap-icons-1.4.0/bootstrap-icons.svg#calendar2-plus-fill"/>
                </svg>
                新增
            </button>
            <button class="btn-danger">
                <svg class="bi" fill="currentColor" width="16" height="16">
                    <use xlink:href="${basePath}static/img/bootstrap-icons-1.4.0/bootstrap-icons.svg#calendar-x"/>
                </svg>
                删除
            </button>
        </div>
    </div>
    <!--表格数据-->
    <div class="row">
        <div class="col-md-12">
            <table class="table table-hover">
                <tr>
                    <th>#</th>
                    <th>empName</th>
                    <th>gender</th>
                    <th>email</th>
                    <th>deptName</th>
                    <th>操作</th>
                </tr>
                <c:forEach items="${pageInfo.list}" var="emp">
                    <tr>
                        <th>${emp.empId}</th>
                        <th>${emp.empName}</th>
                        <th>${emp.gender=="M"?"男":"女"}</th>
                        <th>${emp.email}</th>
                        <th>${emp.department.deptName}</th>
                        <th><button class="btn-primary btn-sm">
                            <svg class="bi" fill="currentColor" width="12" height="12">
                                <use xlink:href="${basePath}static/img/bootstrap-icons-1.4.0/bootstrap-icons.svg#wrench"/>
                            </svg>
                            编辑
                        </button>
                            <button class="btn-danger btn-sm">
                                <svg class="bi" fill="currentColor" width="12" height="12">
                                    <use xlink:href="${basePath}static/img/bootstrap-icons-1.4.0/bootstrap-icons.svg#calendar-x"/>
                                </svg>
                                删除
                            </button></th>
                    </tr>
                </c:forEach>

            </table>
        </div>
    </div>
    <!--分页显示-->
    <div class="row">
        <!--分页文字信息-->
        <div class="col-md-6">
            当前${pageInfo.pages} ,页记录数：${pageInfo.total}
        </div>
        <!--分页条信息-->
        <div class="col-md-6">
            <ul class="pagination">
                <li class="page-item"><a class="page-link" href="${basePath}/Employs?pn=1">首页</a></li>
                <c:if test="${pageInfo.hasPreviousPage}">
                    <li class="page-item"><a class="page-link" href="${basePath}/Employs?pn=${pageInfo.pageNum-1}">
                    <span aria-hidden="true">
                    上一页
                    </span> </a></li>
                </c:if>


                <c:forEach items="${pageInfo.navigatepageNums}" var="page_Num">
                    <c:if test="${page_Num == pageInfo.pageNum}">
                        <li class="page-item active"><a class="page-link" href="#">${page_Num}</a></li>
                    </c:if>
                    <c:if test="${page_Num != pageInfo.pageNum}">
                        <li class="page-item"><a class="page-link" href="${basePath}/Employs?pn=${page_Num}">${page_Num}</a></li>
                    </c:if>
                </c:forEach>
                <c:if test="${pageInfo.hasNextPage}">
                    <li class="page-item"><a class="page-link" href="${basePath}/Employs?pn=${pageInfo.pageNum+1}">下一页</a></li>
                </c:if>

                <li class="page-item"><a class="page-link" href="${basePath}/Employs?pn=${pageInfo.pages}">末页</a></li>
            </ul>
        </div>
    </div>
</div>
</body>
</html>
<script type="text/javascript"></script>
<script type="text/javascript" src="${basePath}static/js/jquery-3.6.0.min.js">
</script>
<!--引入样式-->
<script type="text/javascript" src="${basePath}static/js/bootstrap.js"></script>